package com.yvon.boot.common.validation.annotation;

import com.yvon.boot.common.validation.validator.FlagValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

/**
 * 验证状态是否在指定范围内的注解.
 *
 * <pre>
 *     用法：@Flag(value = {"0","1"},message = "状态只能为0或1")
 *          private Integer sex;
 * </pre>
 *
 * @author : Yvon
 * @since : 2021-06-22
 */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD,ElementType.PARAMETER})
@Constraint(validatedBy = FlagValidator.class)
public @interface Flag {
    /**
     * 价值
     *
     * @return {@link String[] }
     * @author : Yvon / 2021-06-22
     */
    String[] value() default {};

    /**
     * 消息
     *
     * @return {@link String }
     * @author : Yvon / 2021-06-22
     */
    String message() default "输入的状态值有误!";

    /**
     * 组
     *
     * @return {@link Class<?>[] }
     * @author : Yvon / 2021-06-22
     */
    Class<?>[] groups() default {};

    /**
     * 有效载荷
     *
     * @return {@link Class<? extends Payload>[] }
     * @author : Yvon / 2021-06-22
     */
    Class<? extends Payload>[] payload() default {};
}
